package com.singfan.manage.vm;

import com.singfan.manage.vm.partial.IncomeItem;

import java.util.List;

/**
 * Author: hansonghe
 * Date: 2015-10-20 13:08
 * Desc:
 */
public class IncomeModel extends ViewModelBase {
    private String incomeData;

    public String getIncomeData() {
        return incomeData;
    }

    public void setIncomeData(String incomeData) {
        this.incomeData = incomeData;
    }

    public static IncomeModel createWithIncomeItem(List<IncomeItem> incomeItemList){
        IncomeModel incomeModel = new IncomeModel();
        StringBuilder sb = new StringBuilder();
        int price = 0;
        int realPrice = 0;
        for (IncomeItem item : incomeItemList){
            price += item.getPrice();
            realPrice += item.getRealPrice();
            sb.append(item.toString());
        }

        IncomeItem incomeItem = new IncomeItem();
        incomeItem.setDay("汇总");
        incomeItem.setPrice(price);
        incomeItem.setRealPrice(realPrice);
        incomeItem.setCoupon(price - realPrice);

        sb.append(incomeItem.toString());

        incomeModel.setIncomeData(sb.toString());

        return incomeModel;
    }
}
